﻿// Copyright (C) 2009  Lex Li
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

/*
 * Created by SharpDevelop.
 * Date: 10/9/2009
 * Time: 8:10 PM
 */

using System.Drawing;
using System.Windows.Forms;
using Lextm.M8Pack.ThemeBuilder.Properties;
using WeifenLuo.WinFormsUI.Docking;

namespace Lextm.M8Pack.ThemeBuilder
{
	/// <summary>
	/// Standby screen.
	/// </summary>
	internal partial class StandbyScreen : DockContent
	{
		private Theme _current;
		
		public Theme Current
		{
		    private get { return _current; }
			set 
			{ 
				_current = value; 
				Helper.ChangeChildrenVisible(this, _current != null);
			}
		}
		
		public StandbyScreen()
		{
			InitializeComponent();
            TabText = Resources.StandbyScreenTitle;
		}
		
		public void LoadTheme()
		{
			if (Current == null)
			{
				return;
			}

			using(Image b = Helper.LoadImage(Current.StandbyBackgroundImage))
			{
				phoneScreen1.Background = Helper.ShrinkBackground(b);
			}
		}
		
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
		private void PhoneScreen1ShortcutClicked(object sender, Components.ImageBrowsedEventArgs e)
		{
			if (Current == null)
			{
				return;
			}
			
			using(Image image = Helper.LoadImage(e.FileName))
			{
				if (image.Width != 480 || image.Height != 720)
				{
					MessageBox.Show(Resources.JpegImageWarning);
					return;
				}
				
				Current.ReplaceStandbyBackground(e.FileName);
				phoneScreen1.Background = Helper.ShrinkBackground(image);
			}
		}

	    public void SwitchMode()
	    {
	        phoneScreen1.SwitchMode();
	    }
	}
}
